<%@page import="java.util.Iterator"%>
<%@page import="shop.factory.DAOFactory"%>
<%@page import="shop.vo.ProTypeBean"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script src="../js/jquery-2.1.1.min.js" type="text/javascript"
	charset="utf-8"></script>
<link rel="stylesheet" href="../css/bootstrap.min.css">
<title>添加商品</title>
<script type="text/javascript">
function loadChildren() {
	var first = document.getElementById("first").value;
	//alert(first);
	$.ajax({
		async: false,
		cache: true,
		url: "/B2CShop/ProTypeServlet",
		data: { 
			id: first
		},
		type: "POST",
		dataType: "json",
		success: function(arr) {
			var second = $("#second");
			second.empty();
			second.append("<option>==二级分类==</option>");
			//alert(arr);
			for (var i = 0;i < arr.length;i ++) {
				var option = "<option value='" + arr[i].ptypeid + "'>" + arr[i].ptypename + "</option>";
				second.append(option);
				//alert(arr[i].ptypeid + "*******" +arr[i].ptypename);
			}
		}
	})
}
</script>
</head>
<%
	if (!(boolean)session.getAttribute("adminLogin")) {
		String path = request.getContextPath() + "/Admin/login.jsp";
		response.sendRedirect(path);
	}
	List<ProTypeBean> list = DAOFactory.getIProTypeDAOInstance().listYiji();
	Iterator<ProTypeBean> it = list.iterator();
%>
<body>
	<div class="container">
		<h3>添加商品</h3>
		<div class="page-header" style="margin-top:10px;"></div>
		<form action="uploadPro.jsp" method="post" enctype="multipart/form-data">
		<table class="table table-bordered table-condensed table-striped">
				<tr>
					<td align="right">商品名称：</td>
					<td><input type="text" name="proName"></td>
				</tr>
				<tr>
					<td align="right">商品价格：</td>
					<td><input type="text" name="price"></td>
				</tr>
				<tr>
					<td align="right">商品数量：</td>
					<td><input type="text" name="num"></td>
				</tr>
				<tr>
					<td align="right">商品描述：</td>
					<td><textarea rows="" cols="" name="proDescr"></textarea></td>
				</tr>
				<tr>
					<td align="right">商品质量：</td>
					<td><textarea rows="" cols="" name="pro_param"></textarea></td>
				</tr>
				<tr>
					<td align="right">大图：</td>
					<td><input type="file" name="img"></td>
				</tr>
				<tr>
					<td align="right">小图：</td>
					<td><input type="file" name="littleimg"></td>
				</tr>
				<tr>
					<td align="right">类别：</td>
					<td><select value="" id="first" name="first" onchange="loadChildren()">
							<option value="">==一级分类==</option>
							<%
								while (it.hasNext()) {
									ProTypeBean ptype = it.next();
							%>
							<option value="<%=ptype.getPtype_id() %>"><%=ptype.getPtype_name() %></option>
							<%
								}
							%>
						</select>
						<select value="" id="second" name="second">
							<option value="">==二级分类==</option>
						</select>
					</td>
				</tr>
				<tr>
					<td align="center" colspan="3"><input type="submit" value="添加">&nbsp;<input
						type="reset" value="重置"></td>
				</tr>
			</table>
		</form>
	</div>
</body>
</html>